//
//  ZZOrderViewModel.m
//  新项目
//
//  Created by liGordon on 16/12/21.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

#import "ZZOrderViewModel.h"

@implementation ZZOrderViewModel

+(instancetype)shareViewModel{
    static id instance;
    static  dispatch_once_t once;
    dispatch_once(&once, ^{
        instance=[[self alloc] init];
    });
    return instance;
    
}

-(void)getOrderWithCompanyID:(NSString *)companyID andPageIndex:(NSString *)pageIndex andtype:(NSString *)type  andStartTime:(NSString *)StartTime andEndTime:(NSString *)EndTime andPlateNumber:(NSString *)PlateNumber andRepairProperty:(NSString *)RepairProperty andSuccess:(void (^)(NSDictionary *result))success andFailer:(void (^)())failer
{
    NSMutableDictionary *strDic = [NSMutableDictionary dictionary];
    [strDic setKey:@"companyid" forValue:companyID];
       [strDic setKey:@"pageSize" forValue:@(upNum)];
       [strDic setKey:@"pageIndex" forValue:pageIndex];
       [strDic setKey:@"type" forValue:type];//1今日订单，2今日已完成订单，3所有订单
     [strDic setKey:@"StartTime" forValue:StartTime ];
     [strDic setKey:@"EndTime" forValue:EndTime];
     [strDic setKey:@"PlateNumber" forValue:PlateNumber];
     [strDic setKey:@"RepairProperty" forValue:RepairProperty];
    NSString *jsonStr=[WHJSON jsonStringWithObject:strDic];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic setKey:@"data" forValue:jsonStr];
    
    [YBHttpTool post:@"api/CmpOrder/OrderCar/GetOrderCar" params:dic success:^(NSDictionary *obj) {
        DLog(@"=====%@",obj);
        if ([obj isKindOfClass:[NSNull class]] || obj==nil) {
            DLog(@"返回值为空");
            return ;
        }
        success(obj);
        
    } failure:^(NSError *error) {
        DLog(@"%@",error);
        failer();
    }];

}
//获取类型
-(void)getOrderWithCompanyID:(NSString *)companyID andcompanyfid:(NSString *)companyfid
                  andSuccess:(void (^)(NSDictionary *result))success andFailer:(void (^)())failer
{
    NSMutableDictionary *strDic = [NSMutableDictionary dictionary];
    [strDic setKey:@"companyid" forValue:companyID];
    [strDic setKey:@"companyfid" forValue:companyfid];
    [strDic setKey:@"Type" forValue:@"BXXZ1023"];
 
    NSString *jsonStr=[WHJSON jsonStringWithObject:strDic];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic setKey:@"data" forValue:jsonStr];
    
    [YBHttpTool post:@"api/Communal/BasicManage/GetApiCompanyBasic" params:dic success:^(NSDictionary *obj) {
        DLog(@"=====%@",obj);
        if ([obj isKindOfClass:[NSNull class]] || obj==nil) {
            DLog(@"返回值为空");
            return ;
        }
        success(obj);
        
    } failure:^(NSError *error) {
        DLog(@"%@",error);
        failer();
    }];
    
}

@end
